package com.education.wisdom.controller.management;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.education.common.utils.ApiReturnObject;
import com.education.common.utils.LogUtil;
import com.education.common.utils.UUIDUtils;
import com.education.wisdom.pojo.Answers;
import com.education.wisdom.pojo.CatalogAppraisal;
import com.education.wisdom.pojo.Paper;
import com.education.wisdom.pojo.Questions;
import com.education.wisdom.service.IAnswersService;
import com.education.wisdom.service.ICatalogAppraisalService;
import com.education.wisdom.service.IPaperService;
import com.education.wisdom.service.IQuestionsService;
import com.education.wisdom.vo.QuestionsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

import static com.education.common.core.BaseController.writeJSON;


/**
 * 职业技能鉴定目录体系 信息操作处理
 *
 * @author ruoyi
 * @date 2019-06-19
 */
@Controller
@CrossOrigin
@Slf4j
@ResponseBody
@RequestMapping("/manage/catalogAppraisal")
@Api(tags = {"职业技能鉴定板块"})
public class CatalogAppraisalController {

    @Autowired
    private ICatalogAppraisalService catalogAppraisalService;

    //查询
    @GetMapping("/SelectAll")
    public ApiReturnObject selectAll(CatalogAppraisal catalogAppraisal, Integer pageNum, Integer pageSize) {
        if (pageNum != null && pageSize != null) {
            PageHelper.startPage(pageNum, pageSize);
        }
        List<CatalogAppraisal> appraisalList = catalogAppraisalService.selectCatalogAppraisalList(catalogAppraisal);
        return new ApiReturnObject("200", "success", new PageInfo<CatalogAppraisal>(appraisalList));
    }

    //删除
    @GetMapping("/Delete")
    public ApiReturnObject delete(Integer catalogId) {
        catalogAppraisalService.deleteByCatalogId(catalogId);
        return new ApiReturnObject("200", "删除成功", "删除成功");
    }

    //增加
    @PostMapping("/ins")
    public ApiReturnObject insert(@RequestBody CatalogAppraisal catalogAppraisal) {
        catalogAppraisal.setCreateTime(new Date());
        catalogAppraisalService.insertCatalogAppraisal(catalogAppraisal);
        return new ApiReturnObject("200", "添加成功", "添加成功");
    }

    //修改
    @PostMapping("/update")
    public ApiReturnObject update(@RequestBody CatalogAppraisal catalogAppraisal) {
        catalogAppraisalService.updateCatalogAppraisal(catalogAppraisal);
        return new ApiReturnObject("200", "添加成功", "添加成功");
    }
}
